﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cvk.News;

namespace BatDongSan.Modules
{
    public partial class Uct_News_Top : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GetHotNews(1);
        }
        private void GetHotNews(int ParentId)
        {
            try
            {
                List<VG_New> list = NewsBll.claNews.GetListNews(1, ParentId, 5, true, Utility.strConnect);
                if (list.Count > 0)
                {
                    rptNews.DataSource = list;
                    rptNews.DataBind();
                }
            }
            catch { }
        }

        protected void rptNews_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            try
            {
                if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
                {
                    VG_New info = (VG_New)e.Item.DataItem;
                    HyperLink hplImg = (HyperLink)e.Item.FindControl("hplImg");
                    //hplImg.Text = cvk.AppCode.WebUtility.CatString(info.Subject, 10);
                    //hplImg.ToolTip = info.Subject;
                    hplImg.NavigateUrl = string.Format("/NewsDetail.aspx?idt={0}&id={1}", info.NewsTypeId, info.NewsId);
                    //hplSubject.NavigateUrl = string.Format("http://{0}/{1}/{2}/{3}.htm", Request.Url.Authority, NewsBll.claNewsTypeDetail.GetUrlFriendly(1, info.NewsTypeId, Utility.strConnect), info.NewsId, info.SeoUrl);

                    HyperLink hplTitle = (HyperLink)e.Item.FindControl("hplTitle");
                    hplTitle.NavigateUrl = hplImg.NavigateUrl;
                    hplTitle.Text = info.Subject;

                    Image ImgShow = (Image)e.Item.FindControl("ImgShow");
                    ImgShow.ImageUrl = string.Format("/Uploads/News/{0}", info.ImageThumb);

                    Literal ltrNote = (Literal)e.Item.FindControl("ltrNote");
                    ltrNote.Text = cvk.AppCode.WebUtility.CatString(info.Note, 30);
                }
            }
            catch { }
        }
    }
}